//
//  WHCompanyInfoApplySecendCell.m
//  WHEasyBizLink
//
//  Created by shengmeng chen on 2024/12/9.
//

#import "WHCompanyInfoApplySecendCell.h"
#import "WHCompanyInfoApplyModel.h"
#import "SDAutoLayout.h"

@implementation WHCompanyInfoApplySecendCell

-(void)createUIControls
{
    [super createUIControls];
    
    UIButton*selectBtn = [[UIButton alloc] init];
    [selectBtn setImage:[UIImage imageNamed:@"xuanze1"] forState:UIControlStateNormal];
    [selectBtn setTitle:@"是" forState:UIControlStateNormal];
   
    [selectBtn setImage:[UIImage imageNamed:@"select"] forState:UIControlStateSelected];

    [selectBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [selectBtn setTitleColor:RGBColor(106, 168, 255) forState:UIControlStateSelected];
    
    selectBtn.titleLabel.font =[UIFont systemFontOfSize:20];
    _selectBtn = selectBtn;
    selectBtn.tag = 0;
    selectBtn.selected = YES;
    [selectBtn addTarget:self action:@selector(clickBtn:)
      forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:selectBtn];
    
    UIButton*noSelectBtn = [[UIButton alloc] init];
    [noSelectBtn setImage:[UIImage imageNamed:@"xuanze1"] forState:UIControlStateNormal];
    [noSelectBtn setTitle:@"否" forState:UIControlStateNormal];
    [noSelectBtn setImage:[UIImage imageNamed:@"select"] forState:UIControlStateSelected];
    
    [noSelectBtn setTitleColor:RGBColor(106, 168, 255) forState:UIControlStateNormal];
    noSelectBtn.titleLabel.font =[UIFont systemFontOfSize:20];
    _noSelectBtn = noSelectBtn;
    [self.contentView addSubview:noSelectBtn];
    noSelectBtn.tag = 1;
    [noSelectBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [noSelectBtn setTitleColor:RGBColor(106, 168, 255) forState:UIControlStateSelected];
    
   [noSelectBtn addTarget:self action:@selector(clickBtn:)
      forControlEvents:UIControlEventTouchUpInside];
}

-(void)setUpUIControlsLayout
{
    [super setUpUIControlsLayout];
  
    /**   标题,标题  **/
//    self.titleLabel.sd_layout.
//    topSpaceToView(self.contentView,kMarginH)
//    .leftSpaceToView(self.contentView,kMarginW*2)
//    .rightSpaceToView(self.contentView,kMarginW*2)
//    .autoHeightRatio(0);
    
    self.selectBtn.sd_layout.
    topSpaceToView(self.titleLabel,10)
    .leftSpaceToView(self.contentView,kMarginW*2)
    .widthIs(40)
    .heightIs(30);
    
    self.noSelectBtn.sd_layout.
    topSpaceToView(self.titleLabel,10)
    .leftSpaceToView(self.selectBtn,kMarginW*4)
    .widthIs(40)
    .heightIs(30);
}

-(void)setModel:(WHCompanyInfoApplyModel *)model
{
    [super setModel: model];
    self.titleLabel.text      = model.titleName;
    self.textField.placeholder= model.holderName;
    self.textField.hidden      =YES;
    self.xingLabel.hidden     = !model.isMust;
    model.contents =model.contents.length==0? @"1":model.contents;
}

-(void)clickBtn:(UIButton*)btn
{
    btn.selected = YES;
    if (btn.tag==0) {
        self.noSelectBtn.selected = NO;
        self.model.contents = @"1";
    }else if (btn.tag ==1)
    {
        self.selectBtn.selected = NO;
        self.model.contents = @"0";
    }
    
}

@end
